package io.gitee.minelx.filesystem.provider;

import io.gitee.minelx.filesystem.Directory;
import io.gitee.minelx.filesystem.Locator;
import io.gitee.minelx.filesystem.values.PathDescription;

import java.nio.file.FileSystems;

import static io.gitee.minelx.filesystem.init.OpenPolicy.EXISTS;

public interface FS {
	FS LOCAL_FS = of(FileSystems.getDefault());

	FS NOT_IMPLEMENTED_FS = new NotImplementedFS();

	String schemaAndAuthority();

	PathMethodProvider provider(PathDescription description);

	default Locator locate() {
		return new Locator(this, PathDescription.root());
	}

	static FS of(java.nio.file.FileSystem fileSystem) {
		return new JavaFS(fileSystem);
	}

	static FS notImplemented() {
		return NOT_IMPLEMENTED_FS;
	}

	static Locator local() {
		return LOCAL_FS.locate();
	}

	static Directory workingDir() {
		return local().dir(System.getProperty("user.dir").replace('\\', '/'), EXISTS);
	}
}
